package com.example.demo.controller;

import com.example.demo.constant.ResultCode;
import com.example.demo.exception.TokenException;
import com.example.demo.util.Result;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class DemoController {

    @GetMapping("/public")
    public Result<String> publicEndpoint() {
//        return Result.error(ResultCode.ERROR);
        return Result.success("001");
    }

    @GetMapping("/user")
    public String userEndpoint() {
        return "This is a user endpoint. Only authenticated users can access this.";
    }

    @GetMapping("/admin")
    public String adminEndpoint() {
        return "This is an admin endpoint. Only admins can access this.";
    }

    @GetMapping("/test")
    public String test() {
        return "test";
    }
}